<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://www.bstek.com/dorado" prefix="d" %>
<%@ page import="java.util.*"%>
<%@ page import="com.bstek.dorado.view.*"%>
<%@ page import="com.bstek.dorado.data.*"%>
<%@ page import="com.sibco.client.common.Tools"%>
<html>
<head>
<title></title>
</head>
<body>
<%@ include file="/jsp/js/Common.js" %>
  <d:View config="com.sibco.client.business.socialAccEmpView">
     <d:AutoForm id="form1" />
    <%       
    ViewModel viewModel = JspHelper.getViewModel(pageContext);
    Dataset dsSs= (Dataset)viewModel.getDataset("datasetEmpSS");         
    String theYear=Tools.toStr(dsSs.parameters().getString("the_year"));
    String curMonth=Tools.toStr(dsSs.parameters().getString("cur_month"));    
    String tmp=Tools.toStr(dsSs.parameters().getString("adjust_month"));
    int adjustMonth=1;
    System.out.println("aaa:"+theYear+"||"+curMonth+":"+tmp);
    if (!"".equals(tmp)){
       adjustMonth=new Integer(tmp).intValue();
    }
    String scope1=(Integer.parseInt(Tools.getSysdate("yyyy"))-1)+(adjustMonth<10?"0"+adjustMonth:""+adjustMonth);
    System.out.println("scope:"+scope1);
    int iRows=0;
    if (!theYear.equals("")){
        for (int i=1;i<=12;i++){
           String theMonth=i+"";
           if (i<10){
              theMonth="0"+i;
           }
           String loopMonth=theYear+theMonth;
           if (Long.parseLong(loopMonth)<Long.parseLong(scope1)){
               continue;
           }
           if (Long.parseLong(loopMonth)>Long.parseLong(curMonth)){
               break;
           }
       %>
           <table border="0" width="100%" bgcolor=<%=(iRows%2==0?"#e0e0e0":"#f4f4f4")%>>
             <tr>
              <td colspan="6"><font color="blue">月份：<%=theYear%>-<%=theMonth%></font></td>          
             </tr> 
             <tr>
              <td width="10%"><b>险种</b></td>
              <td width="15%"><b>基数</b></td>
              <td width="20%"><b>金额</b></td>
              <td width="20%"><b>企业金额</b></td>
              <td width="20%"><b>个人金额</b></td>         
              <td width="15%"><b>备注</b></td>          
             </tr> 
        <%
            dsSs.moveFirst();
            while(!dsSs.isLast()){
               if (dsSs.getString("THE_TYPE").equals("1")){
                  String fundMonth=Tools.toStr(dsSs.getString("FUND_MONTH"));
                  String startMonth=Tools.toStr(dsSs.getString("START_MONTH"));
                  String endMonth=Tools.toStr(dsSs.getString("END_MONTH"));
                  if (Long.parseLong(startMonth)<Long.parseLong(fundMonth)) startMonth=fundMonth;
                  if (endMonth.equals("")) endMonth="999999";             
                  if(Long.parseLong(startMonth)<=Long.parseLong(loopMonth) && Long.parseLong(endMonth)>=Long.parseLong(loopMonth)){
        %>
                     <tr>
                      <td><%=dsSs.getString("PRODUCT_NAME")%></td>
                      <td><%=dsSs.getString("BASE")%></td>
                      <td><%=dsSs.getString("MONEY")%></td>
                      <td><%=dsSs.getString("E_MONEY")%></td>
                      <td><%=dsSs.getString("P_MONEY")%></td>         
                      <td>正常缴纳</td>          
                     </tr> 
        <%
                  }
               }
               if (dsSs.getString("THE_TYPE").equals("2")){
                  String fundMonth=Tools.toStr(dsSs.getString("BU_FUND_MONTH"));
                  String startMonth=Tools.toStr(dsSs.getString("BU_START_MONTH"));
                  String endMonth=Tools.toStr(dsSs.getString("BU_END_MONTH"));
                  if (endMonth.equals("")) endMonth="999999";             
                  if(Long.parseLong(startMonth)<=Long.parseLong(loopMonth) && Long.parseLong(endMonth)>=Long.parseLong(loopMonth)){
                     
        %>
                     <tr>
                      <td><%=dsSs.getString("PRODUCT_NAME")%></td>
                      <td><%=dsSs.getString("BASE")%></td>
                      <td><%=dsSs.getString("MONEY")%></td>
                      <td><%=dsSs.getString("E_MONEY")%></td>
                      <td><%=dsSs.getString("P_MONEY")%></td>         
                      <td><%=fundMonth%> 补缴</td>          
                     </tr> 
        <%
                  }
               }
               dsSs.moveNext();
            }//while
        %>
             
           </table>
       <%   
           iRows++;
        }//for
     }
       %>
  </d:View>
</body>
</html>
